home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 98 / Skunkware 98.iso / src / mail / pine3.96.tar.gz / pine3.96.tar / pine3.96 / pine / osdep / hostname.una < prev    next >
Text File  |  1993-07-15  |  679b  |  30 lines

  1. #include <sys/utsname.h>
  2.  
  3. /*----------------------------------------------------------------------
  4.        Call system gethostname
  5.  
  6.   Args: hostname -- buffer to return host name in 
  7.         size     -- Size of buffer hostname is to be returned in
  8.  
  9.  Result: returns 0 if the hostname is correctly set,
  10.          -1 if not (and errno is set).
  11.  ----*/
  12. hostname(hostname,size) 
  13.     char *hostname;
  14.     int size;
  15. {
  16.     /** This routine compliments of Scott McGregor at the HP
  17.         Corporate Computing Center **/
  18.      
  19.     int uname();
  20.     struct utsname name;
  21.  
  22.     (void)uname(&name);
  23.     (void)strncpy(hostname,name.nodename,size-1);
  24.  
  25.     hostname[size - 1] = '\0';
  26.     return 0;
  27. }
  28.  
  29.  
  30.